package com.tuniu.utils;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;
//声明一个类继承ScrollView
public class ObservableScrollView extends ScrollView {


	    public ObservableScrollView(Context context) {
	        super(context);
	    }

	    public ObservableScrollView(Context context, AttributeSet attrs,
	                                int defStyle) {
	        super(context, attrs, defStyle);
	    }

	    public ObservableScrollView(Context context, AttributeSet attrs) {
	        super(context, attrs);
	    }


	    @Override
	    protected void onScrollChanged(int x, int y, int oldx, int oldy) {
	        super.onScrollChanged(x, y, oldx, oldy);
	        //监听时机
	        if (onScollChangedListener != null) {
	            onScollChangedListener.onScrollChanged(y);
	        }
	    }
	  //声明接口，用于传递数据  
	    public interface OnScollChangedListener {
	        void onScrollChanged(int height);
	    }
	    //私有成员变量
	    private OnScollChangedListener onScollChangedListener = null;
	
	    //监听事件
	    public void setOnScollChangedListener(OnScollChangedListener l) {
	    	this.onScollChangedListener = l;
	    }
	
}
